/**
 * 项目名称: Topic_1022.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月13日15时49分13秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    vector<string> vs;

    void pre(TreeNode *root, string vn) {
        if (root) {
            vn += to_string(root->val);
            if (!root->left && !root->right)vs.push_back(vn);
            pre(root->left, vn);
            pre(root->right, vn);
        }
    }

    int Atoi(string s, int radix) {
        int ans = 0;
        for (int i = 0; i < s.size(); i++) {
            char t = s[i];
            if (t >= '0' && t <= '9')ans = ans * radix + t - '0';
            else ans = ans * radix + t - 'a' + 10;
        }
        return ans;
    }

    int sumRootToLeaf(TreeNode *root) {
        pre(root, "");
        int sum = 0;
        for (auto x: vs) {
            sum+= Atoi(x,2);
            cout<<sum<<endl;
        }
        return sum;
    }
};

int main() {

    return 0;
}
